import { terminalStore } from "../store";

const autoRootFontSize = () => {
    const html = document.documentElement;
    const { width } = html.getBoundingClientRect();
    const minValue = Math.min(screen.width, width);
    const fix = terminalStore().flag === 'windows' ? 16 : 64
    
    const value = minValue / 1024 * fix;
    html.style.fontSize = `${value < 18 ? 18 : value}px`;

    terminalStore().setClientWidth(minValue)
}

export const cssToRem = () => {
    window.addEventListener('resize', autoRootFontSize);
    autoRootFontSize();
}